package com.example.controller.TestMyBatisPlus;

import com.example.config.ErrorCodeEnum;
import com.example.controller.BaseController;
import com.example.mapper.UsersMapper;
import com.example.pojo.Users;
import com.power.common.model.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping(value = "/testMyBatisPlus")
public class TestMyBatisPlusController extends BaseController {

    @Autowired
    private UsersMapper mapper;

    @RequestMapping(value = "/select")
    public  void  select(Integer id, HttpServletResponse response){
        try {
            Users users = mapper.selectByPrimaryKey(id);
            this.writeJson(CommonResult.ok(ErrorCodeEnum.Select_SUCCESS).setResult(users),response);
        } catch (Exception e) {
            e.printStackTrace();
            this.writeJson(CommonResult.fail(ErrorCodeEnum.Select_Fail),response);
        }
    }



}
